<template>
  <el-container>
    <el-header>
      <Header title="修改药品"></Header>
    </el-header>
    <el-main>
      <div class="main_bg">
        <div class="border">
          <el-form :model="formInline" class="demo-form-inline">
            <el-form-item label="药品名称：">
              <el-input
                v-model="formInline.name"
                placeholder="请输入药品名称"
                style="width: 500px"
              ></el-input>
            </el-form-item>
            <el-form-item label="规格：">
              <el-input
                v-model="formInline.specification"
                placeholder="请输入规格"
                style="width: 500px; margin-left: 27px"
              ></el-input>
            </el-form-item>
            <el-form-item label="单位：">
              <el-input
                v-model="formInline.monad"
                placeholder="请输入单位"
                style="width: 500px; margin-left: 27px"
              ></el-input>
            </el-form-item>
            <el-form-item label="价格：">
              <el-input
                v-model="formInline.price"
                placeholder="请输入价格"
                style="width: 500px; margin-left: 27px"
              ></el-input>
            </el-form-item>
            <el-form-item label="药品类型：">
              <el-input
                v-model="formInline.type"
                placeholder="请输入药品类型"
                style="width: 500px"
              ></el-input>
            </el-form-item>
          </el-form>
        </div>
        <el-row>
          <el-col :span="12">
            <el-button
              type="success"
              @click="adddrugs"
              style="margin-left: 720px; margin-top: 30px"
              >保存</el-button
            >
          </el-col>
          <el-col :span="12">
            <router-link :to="{ path: '/manage/j_AllPrescription' }">
              <el-button type="primary" style="margin-top: 30px"
                >取消</el-button
              >
            </router-link>
          </el-col>
        </el-row>
      </div>
    </el-main>
  </el-container>
</template>

<script>
import Header from "./../common/PageHeader.vue";
export default {
  data: function () {
    return {
      formInline: {
        name: this.$route.query.drugName,
        specification: this.$route.query.specifications,
        monad: this.$route.query.manufactor,
        price: this.$route.query.sellPrice,
        type: this.$route.query.chargeType,
      },
      dangerlist: [
        {
          name: "阿莫西林",
          price: "￥25",
          dosage: "一天两次、一次2粒",
        },
      ],
    };
  },
  components: {
    Header,
  },
  methods: {
    adddrugs() {
      console.log(this.$route.query.id);
      let id = this.$route.query.id;
      let drugName=this.$route.query.drugName
      let specifications=this.$route.query.specifications
      let sellPrice=this.$route.query.sellPrice
      let manufactor=this.$route.query.manufactor
      let chargeType=this.$route.query.chargeType

      this.axios({
        method: "post",
        url: "/drug/update",
        data: {
          drugName: this.formInline.name, //名称
          specifications: this.formInline.specification, 
          id:id,//规格
          sellPrice: this.formInline.price, //价格
          manufactor: this.formInline.monad, //单位
          chargetype: this.formInline.type, //药品类型
        },
      })
      .then((res)=>{
        this.$router.push('/manage/j_AllPrescription')
        this.$message({
                message: "修改药品成功了喔！！！",
                type: "success",
              });
        console.log(res);
      })
      .catch
    },
    Delete() {},
  },
};
</script>

<style scoped>
.main_bg {
  background-color: rgb(255, 255, 255);
  border: 1px solid rgb(182, 179, 179);
  /* height: 500px; */
  border-radius: 5px;
  padding: 20px;

  box-shadow: 0 0 3px 1px rgb(136, 135, 135);
}
.border {
  border: 1px solid rgb(182, 179, 179);
  border-radius: 5px;
  padding: 20px;
}
</style>